package com.diqizu.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.diqizu.entity.MessaGeEntity;
import com.diqizu.entity.Users;


import com.diqizu.utli.DBManager;
import com.diqizu.utli.QueryDataResult;



/**
 * 
 * @author ������
 *
 */




/**
 * 
 * @author ������
 *
 */
public class UserDaoImpl {
	/**
	 * ��ѯ�û��Ƿ���� �Ƿ���ȷ
	 * @return
	 */
	public boolean getUsers(String userName,String userPwd) {
		String sql = "select * from users where userName='"+userName+"' and userPwd='"+userPwd+"' ";
		System.out.println(sql);
		  ArrayList<MessaGeEntity> list = new ArrayList<>();
		QueryDataResult executeQuery = DBManager.execQuery(sql);
		if(executeQuery != null) {
			ResultSet rs = executeQuery.rs;
			try {
				  while (rs.next()) {
			          MessaGeEntity e = new MessaGeEntity(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4),

			              rs.getString(5), rs.getString(6));
			          list.add(e);
			          return true;
			        }
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally {
				executeQuery.close();
			}
		}
		return false;
	}
	
	/**
	 * �޸ķ���
	 * @param 
	 * @return
	 */
	public boolean updateUsers(String pwd,String userName) {
		String sql = "update users set userPwd='"+pwd+"' where userName='"+userName+"'";
		System.out.println(sql);
		boolean i = DBManager.execUpdate(sql);
		if(i==true) {
			return true;
		}
		return false;
	}
	
	/**
	 * ��ѯ
	 * @param 
	 * @return
	 */
	

}
